package factories;

import date.Date;
import date.DateAmerican;
import date.DateFrench;

public class DateFactory {
	
	/**
	 * Creates an Phone with the format of the specified country as a String and validates it
	 * @param type - the country date format ; date -  the actual date
	 * @return new Date of the specified type;
	 * @return null if the type specified is inexistend or the validation failed
	 */
	public static Date createDate(String type,Long date){
		Date ret;
		if (type.equals("american")){
			ret=new DateAmerican(date);
			return ret.valid(date)?ret:null;
		}
		if (type.equals("french")){
			ret=new DateFrench(date);
			return ret.valid(date)?ret:null;
		}
		return null;
	}
}
